<?php

$__FILEPATH__ = dirname(__FILE__)."/";

require_once($__FILEPATH__."../func_common.php");
require_once($__FILEPATH__."../class_def.php");
require_once($__FILEPATH__."../conf/info.php");
require_once("$fckeditorpath");

CheckAdminAndInitHeader();

$mysqli = GetMysqliInstance();

if(isset($_POST["add"]))
{
    $ret = false;
    if($_POST["title"] != "" && $_POST["content"] != ""){
        $title = $_POST["title"];
        $content = $_POST["content"];
        $time = GetSysTime();
        $ip = GetRequestIp();
        $user = $_SESSION["user"];

    	$str="insert into newslist(title, content, user, ip, time) values(?, ?, ?, ?, ?)";
        $stmt = $mysqli->prepare($str);
        $stmt->bind_param("sssss", $title, $content, $user, $ip, $time);
        $ret = $stmt->execute();
        $stmt->close();
    }

    if ($ret)
        echo "添加成功！<br /><a href=\"addnews.php\">继续添加</a>";  
    else 
        echo "<p style=\"color:red\">添加失败，所有内容都不能为空</p><a href=\"addnews.php\">返回继续</a>";
    exit(0);
}

$mysqli->close();

?>
